<?php

/**
 * This is the model class for table "buildingconstruction".
 *
 * The followings are the available columns in table 'buildingconstruction':
 * @property integer $Id
 * @property integer $NoOfStorey
 * @property double $HeightOfBldg
 * @property string $PortionOccupied
 * @property double $AreaPerFlr
 * @property string $Beams
 * @property string $Columns
 * @property string $Flooring
 * @property double $TotalFlrArea
 * @property string $ExteriorWalls
 * @property string $CorridorWalls
 * @property string $RoomPartitions
 * @property string $MainStair
 * @property string $Windows
 * @property string $Ceiling
 * @property string $MainDoor
 * @property string $Trusses
 * @property string $Roof
 * @property double $TotalFlrAreaOccupied
 * @property integer $Establishment_Id
 *
 * The followings are the available model relations:
 * @property Establishments $establishment
 */

class Buildingconstruction extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */

	public function tableName()
	{
		return 'buildingconstruction';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('NoOfStorey, Establishment_Id', 'numerical', 'integerOnly'=>true),
			array('HeightOfBldg, AreaPerFlr, TotalFlrArea, TotalFlrAreaOccupied', 'numerical'),
			array('PortionOccupied, Beams, Columns, Flooring, ExteriorWalls, CorridorWalls, RoomPartitions, MainStair, Windows, Ceiling, MainDoor, Trusses, Roof', 'length', 'max'=>45),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('Id, NoOfStorey, HeightOfBldg, PortionOccupied, AreaPerFlr, Beams, Columns, Flooring, TotalFlrArea, ExteriorWalls, CorridorWalls, RoomPartitions, MainStair, Windows, Ceiling, MainDoor, Trusses, Roof, TotalFlrAreaOccupied, Establishment_Id', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'establishment' => array(self::BELONGS_TO, 'Establishments', 'Establishment_Id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'Id' => 'ID',
			'NoOfStorey' => 'No. Of Storey',
			'HeightOfBldg' => 'Height Of Bldg.',
			'PortionOccupied' => 'Portion Occupied.',
			'AreaPerFlr' => 'Area Per Flr.',
			'Beams' => 'Beams',
			'Columns' => 'Columns',
			'Flooring' => 'Flooring',
			'TotalFlrArea' => 'Total Flr. Area',
			'ExteriorWalls' => 'Exterior Walls',
			'CorridorWalls' => 'Corridor Walls',
			'RoomPartitions' => 'Room Partitions',
			'MainStair' => 'Main Stair',
			'Windows' => 'Windows',
			'Ceiling' => 'Ceiling',
			'MainDoor' => 'Main Door',
			'Trusses' => 'Trusses',
			'Roof' => 'Roof',
			'TotalFlrAreaOccupied' => 'Total Floor Area Occupied',
			'Establishment_Id' => 'Establishment',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('Id',$this->Id);
		$criteria->compare('NoOfStorey',$this->NoOfStorey);
		$criteria->compare('HeightOfBldg',$this->HeightOfBldg);
		$criteria->compare('PortionOccupied',$this->PortionOccupied,true);
		$criteria->compare('AreaPerFlr',$this->AreaPerFlr);
		$criteria->compare('Beams',$this->Beams,true);
		$criteria->compare('Columns',$this->Columns,true);
		$criteria->compare('Flooring',$this->Flooring,true);
		$criteria->compare('TotalFlrArea',$this->TotalFlrArea);
		$criteria->compare('ExteriorWalls',$this->ExteriorWalls,true);
		$criteria->compare('CorridorWalls',$this->CorridorWalls,true);
		$criteria->compare('RoomPartitions',$this->RoomPartitions,true);
		$criteria->compare('MainStair',$this->MainStair,true);
		$criteria->compare('Windows',$this->Windows,true);
		$criteria->compare('Ceiling',$this->Ceiling,true);
		$criteria->compare('MainDoor',$this->MainDoor,true);
		$criteria->compare('Trusses',$this->Trusses,true);
		$criteria->compare('Roof',$this->Roof,true);
		$criteria->compare('TotalFlrAreaOccupied',$this->TotalFlrAreaOccupied);
		$criteria->compare('Establishment_Id',$this->Establishment_Id);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return Buildingconstruction the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
